package com.ruoyi.project.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.business.domain.Slpaper;
import com.ruoyi.project.business.service.ISlpaperService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 申论试卷管理Controller
 *
 * @author hongwj
 * @date 2024-11-21
 */
@RestController
@RequestMapping("/business/slpaper" )
@Slf4j
public class SlpaperController extends BaseController {
    @Autowired
    private ISlpaperService slpaperService;

    /**
     * 查询申论试卷管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(Slpaper slpaper) {
        startPage();
        List<Slpaper> list = slpaperService.selectSlpaperList(slpaper);
        return getDataTable(list);
    }

    /**
     * 查询所有申论试卷管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:all')" )
    @Log(title = "申论试卷管理" , businessType = BusinessType.OTHER)
    @GetMapping("/all/slpapers" )
    public AjaxResult all(Slpaper slpaper) {
        List<Slpaper> list = slpaperService.selectSlpaperList(slpaper);
        return success(list);
    }

    /**
     * 导出申论试卷管理列表
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:export')" )
    @Log(title = "申论试卷管理" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, Slpaper slpaper) {
        List<Slpaper> list = slpaperService.selectSlpaperList(slpaper);
        ExcelUtil<Slpaper> util = new ExcelUtil<Slpaper>(Slpaper. class);
        util.exportExcel(response, list, "申论试卷管理数据" );
    }

    /**
     * 获取申论试卷管理详细信息
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return success(slpaperService.selectSlpaperById(id));
    }

    /**
     * 新增申论试卷管理
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:add')" )
    @Log(title = "申论试卷管理" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Slpaper slpaper) {
        return toAjax(slpaperService.insertSlpaper(slpaper));
    }

    /**
     * 修改申论试卷管理
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:edit')" )
    @Log(title = "申论试卷管理" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Slpaper slpaper) {
        return toAjax(slpaperService.updateSlpaper(slpaper));
    }

    /**
     * 删除申论试卷管理
     */
    //@PreAuthorize("@ss.hasPermi('business:slpaper:remove')" )
    @Log(title = "申论试卷管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(slpaperService.deleteSlpaperByIds(ids));
    }
}
